// map.js
Page({
  data: {
    latitude: 40.060539,
    longitude: 116.343847,
    dialogVisible: false
  },
  onLoad({
    id
  }) {
    this.getRepairDetail(id)
  },
  async getRepairDetail(id) {
    const {
      code,
      data
    } = await wx.http.get(`/repair/${id}`)
    if (code !== 10000) return wx.utils.toast()
    this.setData(data)
  },
  cancelRepair() {
    this.setData({
      dialogVisible: true
    })
  },
  dialogClose(e) {
    if (e.detail === 'confirm') this.cancelRepairAPI()
  },
  async cancelRepairAPI() {
    const {
      code
    } = await wx.http.put(`/cancel/repaire/${this.data.id}`)
    if (code !== 10000) return wx.utils.toast('取消失败')
    wx.navigateBack()
  },
  editRepair() {
    wx.navigateTo({
      url: '/repair_pkg/pages/form/index?id=' + this.data.id,
    })
  }
})